import { managementService } from '~/config/server'
import { NetService } from '~/utils/net.service'
import { Inject, Debounce } from "~/core/decorator";
import { FilterService } from "~/utils/filter.service";
import { PageService } from "~/utils/page.service";
import { SortService } from "~/utils/sort.service";
import { Service } from "~/core/service"

export class BatchManageService extends Service {

  @Inject(NetService)
  private netService: NetService
  /**
   * 查询批量处理
   * @param data 查询参数实体
   */
  public queryBatchManage(page: PageService): any {
    return this.netService.send({
      server: managementService.batchManageController.queryBatchManage,
      page
    })
  }

  /**
   * 执行触发器
   * @param data  
   */
  public doBatchManage(data): any {
    return this.netService.send({
      server: managementService.batchManageController.doBatchManage,
      data:{
        triggerGroup:data.triggerGroup,
        triggerName:data.triggerName
      }
    })
  }

  /**
   * 修改时间
   * @param data 
   */
  @Debounce()
  public modifyCronJob(data): any {
    return this.netService.send({
      server: managementService.batchManageController.modifyCronJob,
      data
    })
  }

  /**
   * 暂停触发器
   * @param data 
   */
  @Debounce()
  public pauseTriggerForJob(data): any {
    return this.netService.send({
      server: managementService.batchManageController.pauseTriggerForJob,
      data:{
        triggerGroup:data.triggerGroup,
        triggerName:data.triggerName
      }
    })
  }

  /**
   * 启用触发器
   */
  @Debounce()
  public resumeTriggerForJob(data): any {
    return this.netService.send({
      server: managementService.batchManageController.resumeTriggerForJob,
      data:{
        triggerGroup:data.triggerGroup,
        triggerName:data.triggerName
      }
    })
  }
}
